package com.example.peibei.ui.adapter;

import android.widget.ImageView;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.dingtao.common.bean.Order;
import com.dingtao.common.util.GlideUtils;
import com.example.peibei.R;

import java.util.List;

public class OrderLikeListAdapter extends BaseQuickAdapter<Order.RecordsDTO, BaseViewHolder> {

    public OrderLikeListAdapter(@Nullable List<Order.RecordsDTO> data) {
        super(R.layout.item_order_list_like, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, Order.RecordsDTO item) {
        ImageView head = helper.getView(R.id.iv_head);
//        Glide.with(getContext()).load(item.getImageUrl()).apply(RequestOptions.bitmapTransform(new CircleCrop())).into(head);
//        if (TextUtils.isEmpty(item.getImageUrl())) {
//            GlideUtils.loadImg(getContext(), item.getImgUrl(), 20, head);
//        } else {
//            GlideUtils.loadImg(getContext(), item.getImageUrl(), 20, head);
//        }
        if (item.getImgs()!=null) {
            GlideUtils.loadImg(getContext(), item.getImgs().get(0), 20, head);
        } else {
            GlideUtils.loadImg(getContext(), item.getImgs().get(0), 20, head);
        }
        helper.setText(R.id.tv_name, item.getNickName()).setText(R.id.tv_address, item.getArea()).setText(R.id.tv_dec, item.getOtherDesc()).setText(R.id.tv_cate, item.getCategory())
                .setText(R.id.tv_online, item.getOnline());
        if (item.getPrice().contains(".")) {
            String[] split = item.getPrice().split("\\.");
            helper.setText(R.id.tv_price, split[0]);
        } else {
            helper.setText(R.id.tv_price, item.getPrice());
        }
//        List<String> imgs = item.getImgs();
//        LinearLayout llImgs = helper.getView(R.id.ll_imgs);
//        ImageView imgOne = helper.getView(R.id.iv_img_one);
//        ImageView imgTwo = helper.getView(R.id.iv_img_two);
//        ImageView imgThree = helper.getView(R.id.iv_img_three);
//        if (imgs.size() > 0) {
//            llImgs.setVisibility(View.VISIBLE);
//            if (imgs.get(0) != null && !imgs.get(0).equals("")) {
//                Glide.with(getContext()).load(imgs.get(0)).into(imgOne);
//            }
//            if (imgs.size() > 1 && imgs.get(1) != null && !imgs.get(1).equals("")) {
//                Glide.with(getContext()).load(imgs.get(1)).into(imgTwo);
//            }
//            if (imgs.size() > 2 &&imgs.get(2) != null && !imgs.get(2).equals("")) {
//                Glide.with(getContext()).load(imgs.get(2)).into(imgThree);
//            }
//        } else {
//            llImgs.setVisibility(View.GONE);
//        }
    }
}
